package pri.zxx.webdemo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import pri.zxx.webdemo.interceptor.CustomHandleInterceptor;

import java.util.List;

/**
 * @author Twilight
 * @desc
 * @createTime 2020-05-03-10:41
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

	@Autowired
	private List<CustomHandleInterceptor> customHandlerCeptors;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		customHandlerCeptors.forEach(registry::addInterceptor);
	}


	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/**")
				.addResourceLocations("classpath:/META-INF/resources/")
				.addResourceLocations("classpath:/static/");

		registry.addResourceHandler("/webjars/**")
				.addResourceLocations("classpath:/META-INF/resources/webjars/");
	}
}


